# Build stage
FROM golang:1.17-alpine AS build
WORKDIR /app

# Copy and download dependencies
COPY go.mod ./
RUN go mod download

# Copy the rest of the code
COPY *.go ./

# Build the application
RUN CGO_ENABLED=0 GOOS=linux go build -o user-service

# Final stage
FROM alpine:3.14
WORKDIR /app

# Install necessary packages
RUN apk --no-cache add ca-certificates tzdata

# Copy binary from build stage
COPY --from=build /app/user-service .

EXPOSE 8080 9090
CMD ["./user-service"] 